package com.boot.proofing.mpweb.base.service.impl;/**
 * @description
 * @autor xbwu on 2018/5/25.
 */

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.boot.core.service.impl.BaseMPServiceImpl;
import com.boot.proofing.mpweb.base.entity.DataDictionary;
import com.boot.proofing.mpweb.base.mapper.DataDictionaryMapper;
import com.boot.proofing.mpweb.base.service.IDataDictionaryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * User 表数据服务层接口实现类
 */
@Service("dataDictionaryServiceMP")
public class DataDictionaryServiceImpl extends BaseMPServiceImpl<DataDictionaryMapper, DataDictionary> implements IDataDictionaryService {

    @Override
    public String getValue(String key) {
        DataDictionary dd=getByKey(key);
        if(dd!=null){
            return dd.getDateValue();
        }
        return null;
    }

    @Override
    public DataDictionary getByKey(String key) {
        LambdaQueryWrapper uw = Wrappers.<DataDictionary>query().lambda()
                .and(i->i.eq(DataDictionary::getDateKey, key));
        List<DataDictionary> list=list(uw);
        for(DataDictionary dd:list){
            return dd;
        }
        return null;
    }
}